package cn.jinjie.day09;

import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;

public class Test06 {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1, "张三丰", "张无忌", "张翠山", "王二麻子", "张良", "谢广坤");

        //一个stream流对象只能操作一次 filter等中间操作方法 都会返回一个新的流对象
        Stream<String> ss = list1.stream().
                filter(s -> s.startsWith("张")).
                filter(s -> s.length() == 3);
        ss.forEach(System.out::println);
        list1.stream().
                filter(s -> s.startsWith("张")).
                filter(s -> s.length() == 3).
                forEach(System.out::println);
    }
}
